package org.willthink.dao.schedule.impl;

import java.sql.SQLException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.willthink.dao.schedule.ScheduleDAO;
import org.willthink.vo.schedule.ScheduleVO;
import com.ibatis.sqlmap.client.SqlMapClient;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class ScheduleDAOImpl extends SqlMapClientDaoSupport implements ScheduleDAO
{
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	private SqlMapClient sqlMapClient;
	
	@Override
	public ScheduleVO SelectTodaysSchedule(ScheduleVO scheduleVO) throws SQLException 
	{
		// TODO Auto-generated method stub
		logger.debug("ScheduleDAOImpl sqlMapClient : {}", sqlMapClient);
		logger.debug("ScheduleDAOImpl scheduleVo : {}", scheduleVO);
		scheduleVO = (ScheduleVO) getSqlMapClient().queryForObject("scheduler.selectTodaysSchedule", scheduleVO);
		return scheduleVO;
	}

	@Override
	public void InsertNewSchedule(ScheduleVO scheduleVO) throws SQLException 
	{
		// TODO Auto-generated method stub
		logger.debug("ScheduleDAOImpl sqlMapClient : {}", sqlMapClient);
		logger.debug("ScheduleDAOImpl scheduleVo : {}", scheduleVO);
		getSqlMapClient().insert("scheduler.insertNewSchedule", scheduleVO);
	}

	@Override
	public void UpdateRecordedSchedule(ScheduleVO scheduleVO) throws SQLException 
	{
		// TODO Auto-generated method stub
		logger.debug("ScheduleDAOImpl sqlMapClient : {}", sqlMapClient);
		logger.debug("ScheduleDAOImpl scheduleVo : {}", scheduleVO);
		getSqlMapClient().update("scheduler.updateRecordedSchedule", scheduleVO);
	}

	@Override
	public void DeleteRocordedSchedule(ScheduleVO scheduleVO) throws SQLException 
	{
		// TODO Auto-generated method stub
		logger.debug("ScheduleDAOImpl sqlMapClient : {}", sqlMapClient);
		logger.debug("ScheduleDAOImpl scheduleVo : {}", scheduleVO);
		getSqlMapClient().delete("scheduler.deleteRocordedSchedule", scheduleVO);
	}
}

//	@Override
//	public void InsertTest(ScheduleVO scheduleVo) {
//		// TODO Auto-generated method stub		
//		try
//		{
//			logger.debug("ScheduleDAOImpl sqlMapClient : {}", sqlMapClient);
//			logger.debug("ScheduleDAOImpl scheduleVo : {}", scheduleVo);
//			
//			for(int i=0; i<list.size(); i++){
//				Map<String, String> map = list.get(i);
//				getSqlMapClient().insert("scheduler.test", map);
//			}
//		}
//		catch (SQLException e) {
//			// TODO: handle exception
//			e.printStackTrace();
//		}		
//	}

